<!DOCTYPE HTML>
<html>

<head>
  <title>How things are made</title>
  <meta name="description" content="website description" />
  <meta name="keywords" content="website keywords, website keywords" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
  <link rel="stylesheet" type="text/css" href="style/style.css" title="style" />
</head>
<?php
session_start();

?>
<body>
      <div id="header">
      <div id="logo">
        <div id="logo_text">
          <!-- class="logo_colour", allows you to change the colour of the text -->
          <h1><a href="index.php">how things are<span class="logo_colour">Made</span></a></h1>
          <h2>Simple.Different.Creative.</h2>
          </div> 
          
         </div>
      <div id="menubar">
        <ul id="menu">
          <!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
          <li><a href="index.php">Home</a></li>
          <li class="selected"><a href="profileread.php">My Profile</a></li>
          <li><a href="addarticle.php">Add Posts</a></li>
          <li><a href="searcharticle.php">Search Posts</a></li>
          <li><a href="searchuser.php">Search User</a></li>
          <li><a href="sendEmail.php">Contact Us</a></li>
        </ul>
      </div>
    </div>
    <div id="site_content">
      <div class="sidebar">
        <!-- insert your sidebar items here -->
        <h3>Latest User</h3>
<h4>Click to see the user registered details</h4>
        <h5></h5>
        <p>
        <?php
		
		DEFINE ('DB_USER', 'root');
		DEFINE ('DB_PASSWORD', '');
		DEFINE ('DB_HOST', 'localhost');
		DEFINE ('DB_NAME', 'SITEDATABASE');
		$dbc = @mysqli_connect (DB_HOST, DB_USER,DB_PASSWORD, DB_NAME) 
			OR die ('Could not connect to MySQL: ' .mysqli_connect_error() );
		$q = "select * from users ORDER BY registrationtime DESC LIMIT 1";
		$r = @mysqli_query($dbc,$q);
		if($r)
		{
			$row=mysqli_fetch_array($r,MYSQLI_ASSOC);
				
        echo '<p>Click here to see user details<br /><a href="http://localhost/MyBlog/showuser.php?other_user_id='.$row['user_id'].'">'.$row['fname'].' '.$row['lname'].'</a></p>';
		
        echo '<p></p>';
		
		}
		?>
        
        
        </p>
        <p></p>
        <h4>Sponsored Links</h4>
        <h5></h5>
        <p>This space is reserved for 5 advertisement links</p>
        <h3>Social Media Links</h3>
        <ul>
          <div class="footer_text">
         <div class="foot_pad">
          <div class="link1"><a href="http://www.facebook.com/pages/How-Things-Are-Made/377142059843?sk=wall"> Be a fan on Facebook</a></div>
          <div class="link2"><a href="#">Follow us on Twitter</a></div>
          
          </div>
          </div>
        </ul>
        
      </div>
      <div id="content">
        <!-- insert the page content here -->
		<h3>Edit Profile</h3>
       
        <?php
		if($_SESSION['email'])
		{
			$email = $_SESSION['email'];
			//$user = $_SESSION['fname'];
	
			// Make the connection:
			
	
	
			$q = "SELECT * FROM USERS where email = '$email'";
	
			$r = @mysqli_query ($dbc, $q); // Run the query.
			
			if($r)
			{
				$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
				
				
			
			
			}
	
			//mysql_free_result($r);
			
			
			if(isset($_POST['submitted']))
			{
				$fname=$_REQUEST['fname'];
				$lname=$_REQUEST['lname'];
				$password=$_REQUEST['password'];
				$about_user=$_REQUEST['about_user'];
				
				$dbc = @mysqli_connect (DB_HOST, DB_USER,DB_PASSWORD, DB_NAME) 
				OR die ('Could not connect to MySQL: ' .mysqli_connect_error() );
					
				$q="UPDATE users SET fname='$fname',lname='$lname',password=SHA1('$password'),about_user='$about_user'";
				$r=@mysqli_query($dbc,$q);
				echo "Submitting";
				if($r)
				{
					header("Location: http://localhost/MyBlog/index.php");
				}
				else
				{
					echo "Problem in editing profile";
				}
			}
			
			
			
		}
		else
		 {
			header("Location: http://localhost/MyBlog/login.php");
		}
		
       ?>       
       <form action="http://localhost/MyBlog/profileedit.php" method="post">
	<p>First Name : <input type="text" name="fname" size="20" maxlength="20" value="<?php echo $row['fname'] ?>" /></p>
	<p>Last Name : <input type="text" name="lname" size="20" maxlength="20" value="<?php echo $row['lname'] ?>" /></p>
	<p>New Password : <input type="password" name="password" size="25" maxlength="25" /></p>
	<p>Confirm Password : <input type="password" name="password1"size="25" maxlength="25" /></p>
	<p><b>About Yourself:</b>
 <textarea name="about_user" rows="3" cols="40" value=""><?php echo $row['about_user'] ?></textarea>
 </p>

<p><input type="submit" name= "submit" value="Submit" />
   <input type="hidden" name="submitted" value="1" />
   <input type="reset" name="reset" value="reset" /></p>
   
</form>
       
       
      </div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
      Copyright &copy; 2011 | howthingsaremade.com <a href=" ></a> | <a href="" ></a> | <a href=" ></a>
    </div>
  </div>
<div style="text-align: center; font-size: 0.75em;">  <a href="	http://facebook.com/howthingaremade.com"> Designed for E-Business</a>.</div></body>
</html>
